package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Menu;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class MenuVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单id")
    private Integer id;

    @ApiModelProperty(value = "菜单名")
    private String title;

    @ApiModelProperty(value = "图标")
    private String icon;

    @ApiModelProperty(value = "类型:0:菜单;1:iframe;2:外连，3：按钮")
    private Integer type;

    @ApiModelProperty(value = "路径")
    private String path;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "是否隐藏 1true 0false ")
    private Integer hidden;

    @ApiModelProperty(value = "是否隐藏面包屑 1true 0false")
    private Integer breadCrumb;


    @ApiModelProperty(value = "父ID")
    private Integer parentId;

    @ApiModelProperty(value = "是否启用：1启用0禁用")
    private Integer enabled;

    private Date updateTime;

    private Date createTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Menu convert(MenuVO vo) {
        Menu entity = new Menu();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Menu> convertList(List<MenuVO> list) {
        List<Menu> resultList = new ArrayList<>();
        for (MenuVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
